package com.bustle.order.dto.account;

import javax.ejb.EJB;
import javax.ejb.Local;
import javax.ejb.Stateless;

import com.bustle.commons.MapConverter;
import com.bustle.order.data.Account;
import com.bustle.user.dto.user.DtoToUserMapConverter;

@Local
public interface DtoToAccountMapConverter extends MapConverter<AccountDto, Account>
{
  @Stateless
  public class DefaultDtoToAccountMapConverter extends AbstractMapConverter<AccountDto, Account> implements DtoToAccountMapConverter
  {
    @Override
    public void doMapping(AccountDto aSource, Account aDestination)
    {
      aDestination.setIdAccount(aSource.getId());
      aDestination.setUser(dtoToUserMapConverter.map(aSource.getUser(), aDestination.getUser()));
      aDestination.setCreationDate(aSource.getCreationDate());
    }

    @Override
    protected Account build()
    {
      return new Account();
    }

    @EJB
    protected DtoToUserMapConverter dtoToUserMapConverter;
  }
}
